#!/bin/bash

ex()
{
	eval "$@" || (echo "error running $@" && exit 1)
}

if [ $# -lt 1 ]
then
	echo -e "\r\n\tUsage: "`basename $0`" <filename>\r\n"
	exit 1
fi
	
dir=$(dirname $0)
file=$(basename $1 | cut -d. -f 1)

ex ${dir}/run ${dir}/$1 -L ${dir}/test/ic/libic.sig > ${file}.S
ex as -g -o ${file}.o ${file}.S
ex ld -g -o ${file} ${file}.o /usr/lib/crt1.o /usr/lib/crti.o ${dir}/libic.a -lc /usr/lib/crtn.o -dynamic /lib/ld-linux.so.2


